#pragma once

#include <gtest/gtest.h>

class PipingListenerTests : public ::testing::Test
{
protected:
    HANDLE m_hPipeReadyEvent;

    HANDLE m_hThread;
    HANDLE m_hPipeIn;

    char m_pipeBuffer[2048];

    int m_expectedMessageCount;

    std::vector<std::string> m_readMessages;

public:
    PipingListenerTests(void);
    ~PipingListenerTests(void);

    /**
     * Creates a separate thread that will act as the pipe server.
     */
    void SetUp();

    /**
     * Performs assertions related to the successful invocation of SetUp().
     * This method is meant to be called at the beginning of the TEST macro.
     */
    void AssertSetUp() const;

    /**
     * Stops the pipe server thread.
     */
    void TearDown();

    tstring GetPipeName() const;
    bool SignalPipeReady();
    int GetExpectedMessageCount() const;

    /**
     * Adds the message to a collection of read messages. This method is not
     * guaranteed to be thread-safe.
     */
    void NotifyMessageRead(const std::string& messageText);
};
